<?php include('./templete/public/head.php') ?>
<body>
<!--发布金点子-->
<div class="fabu-main fabu-idea-main">
    <div class="main-content">
        <div class="c-list">
            <form id="myform">
                <ul class="comm-table-view">
                    <li class="table-view-cell">
                        <a>
                            <span class="title">标题</span>
                            <span class="line">|</span>
                            <span class="input"><input type="text" name="title" id="title" value=""
                                                       placeholder="标题不少于三个字符"/></span>
                            <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                        </a>
                    </li>
                    <li class="table-view-cell">
                        <a>
                            <span class="title">提议人部门</span>
                            <span class="line">|</span>
                            <span class="input" id="showDepartPicker">
                             <input type="text" name="department_name" id="department_name" value="<?php echo $department[0]['text']?>" placeholder=""
                                    readonly/>
                                <input type="hidden" name="user_department" id="department_id" value="<?php echo $department[0]['value']?>"
                                       placeholder="" readonly/>
                            </span>
                            <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                        </a>
                    </li>
                    <li class="table-view-cell">
                        <a>
                            <span class="title">请选择分类</span>
                            <span class="line">|</span>
                            <span class="input" id="showClassPicker">
                                <input type="text" name="question_classfy" id="className" value="" placeholder="<?php echo $classify[0]['text']?>"
                                       readonly/>
                                <input type="hidden" name="propsoe_type" id="question_classfyid" value="<?php echo $classify[0]['value']?>"
                                       placeholder="" readonly/>
                            </span>
                            <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                        </a>
                    </li>
                    <li class="table-view-cell table-view-cell2">
                        <a>
                            <span>存在问题</span>
                            <div class="fabu-text">
                                <textarea name="questiont"></textarea>
                            </div>
                            <div class="fabu-upload">
                                <img src="_images/icon/upload.jpg" class="showPopover _file_upload"/>
                                <p class="_action"></p>
                                <p class="_action1" onclick="get_file(this)"></p>
                            </div>
                            <button type="button" class="layui-btn _file_uploads" style="display: none">
                            </button>
                            <input type="hidden" name="question_files" id="_problem_file_url" class="_file_url">
                        </a>
                    </li>

                    <li class="table-view-cell table-view-cell2">
                        <a>
                            <span>解决的方法</span>
                            <div class="fabu-text">
                                <textarea name="question_soluton"></textarea>
                            </div>
                            <div class="fabu-upload">
                                <img src="_images/icon/upload.jpg" class="showPopover _file_upload"/>
                                <p class="_action"></p>
                                <p class="_action1" onclick="get_file(this)"></p>
                            </div>
                            <button type="button" class="layui-btn _file_uploads" style="display: none">
                            </button>
                            <input type="hidden" name="question_soluton_files" id="_solution_file_url" class="_file_url">
                        </a>
                    </li>
                    <li class="table-view-cell">
                        <a>
                            <span class="title">是否形成知识产权</span>
                            <span class="line">|</span>
                            <span class="input" id="is_right_doc">
                                <input type="text" id="isRight" value="否" placeholder="" readonly/></span>
                            <input type="hidden" name="is_copyright" id="is_right" value="0" readonly/></span>
                            <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                        </a>
                    </li>
                    <li class="table-view-cell right_type_li" style="display: none">
                        <a>
                            <span class="title">产权类型</span>
                            <span class="line">|</span>
                            <span class="input" id="right_type_doc">
                                <input type="text" id="rightType" value="专利" placeholder="" readonly/></span>
                            <input type="hidden" name="copyright_type" id="right_type" value="1" readonly/></span>
                            <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                        </a>
                    </li>
                </ul>
            </form>
            <div class="comm-btn comm-btn2 fabu-btn">
                <span class="color1 publish">提交</span>
                <!--                <span class="color2">越级提交</span>-->
            </div>
        </div>
    </div>
</div>

</body>
<script src="_js/plug/mui.picker.all.js"></script>
<?php include('./templete/public/script.php') ?>
<script>
    $('.publish').click(function () {
        var param = $('#myform').serializeArray();
        if (!$('#title').val()) {
            layer.msg('请输入标题');
            return false;
        }

        /*
        if(!$('#departid').val()){
            layer.msg('请选择部门');
            return false;
        }
        if(!$('#question_classfyid').val()){
            layer.msg('请选择问题分类');
            return false;
        }
        if(!$('#complete_type').val()){
            layer.msg('请选择完成方式');
            return false;
        }
        */
        layer.msg('信息提交中', {time: 60000, icon: 16, shade: 0.3});
        $.ajax({
            url: '<?php echo url("publish")?>',
            data: param,
            type: 'post',
            success: function (data) {
                if (data.code == 2) {
                    layer.msg(data.msg);
                    return false;
                }
                if (data.code == 1) {
                    layer.msg(data.msg);
                    setTimeout(function () {
                        location.href = '<?php echo url('index')?>'
                    }, 1000)
                } else {
                    layer.msg('发布失败，请联系管理员');
                    setTimeout(function () {
                        layer.closeAll();
                    }, 1000)
                }
            }
        });
    });
    $('._file_upload').click(function () {
        var oThis = $(this).parent().next();
        console.log(oThis);
        oThis.click();
    });
    getSelect(
        "#showDepartPicker",
        <?php echo json_encode($department)?>,
        "#department_name","department_id"
        )
    getSelect("#showClassPicker"
    ,<?php echo json_encode($classify)?>
    ,"#className","#question_classfyid")
    getSelect("#is_right_doc"
        ,[{"value":0,"text":"否"},{"value":1,"text":"是"}]
        ,"#isRight","#is_right")

    getSelect("#right_type_doc"
        ,[{value: '1', text: '专利'}, {value: '2', text: '商业秘密'}]
        ,"#rightType","#right_type")


    function getSelect( ele, data, showname, selectid) {
        var selectName = new mui.PopPicker();
        selectName.setData(data);
        document.querySelector(ele).addEventListener("tap", function () {
            selectName.show(function (items) {
                $(showname).val(items[0].text);
                $(selectid).val(items[0].value);
                if(ele === '#is_right_doc' ){
                    if (items[0].value == 1) {
                        $('.right_type_li').show();
                    }
                }

            });
        });
    }

</script>
</html>